package br.usp.wta.inductor;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import br.usp.language.automata.State;
import br.usp.language.automata.StateMachine;
import br.usp.language.automata.Transition;

public class IvoneTest2 {

    StateMachine fsm2;
    State s0;
    State s1;
    State s2;
    State s3;
    State s4;
    State s5;
    Ivone ivone;

    @Before
    public void setUp() throws Exception {
        // Maquina de teste:
        
        fsm2 = new StateMachine("Teste2");
        s0 = fsm2.getInitialState();
        s1 = fsm2.createState("S1");
        s2 = fsm2.createState("S2");
        s3 = fsm2.createState("S3");
        s4 = fsm2.createState("S4");
        s5 = fsm2.createState("S5");
        s5.setAcceptState();
        
        s0.createTransitionTo(s1, "b", null);
        s0.createTransitionTo(s3, "a", null);
        s1.createTransitionTo(s2, "b", null);
        s1.createTransitionTo(s4, "h", null);
        s2.createTransitionTo(s1, "c", null);
        s2.createTransitionTo(s3, "d", null);
        s2.createTransitionTo(s5, "i", null);
        s3.createTransitionTo(s1, "g", null);
        s3.createTransitionTo(s4, "e", null);
        s4.createTransitionTo(s5, "f", null);
        
        ivone = new Ivone();
        
    }
    
    @Test
    public void testMinimalCycles() {
        ArrayList<State> list = new ArrayList<State>();
        list.add(s0);
        list.add(s1);
        List<Transition> cycle = ivone.findMinimalCycle(fsm2, list, new ArrayList());
        assertEquals(s0,cycle.get(0).getStateFrom());
        assertEquals(s3,cycle.get(0).getStateTo());
        assertEquals(s3,cycle.get(1).getStateFrom());
        assertEquals(s1,cycle.get(1).getStateTo());
    }
    
    @Test
    public void test() {
        ivone.inferAPE(fsm2);
    }
}